<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>清除浮动</title>
    <style>
        .outer {
            border: 1px solid #ccc;
            background: #fc9;
            color: #fff;
            margin: 50px auto;
            padding: 50px;
        }

        .div1 {
            width: 80px;
            height: 80px;
            background: red;
            float: left;
        }

        .div2 {
            width: 80px;
            height: 80px;
            background: blue;
            float: left;
        }

        .div3 {
            width: 80px;
            height: 80px;
            background: sienna;
            float: left;
        }

        .clear {
            clear: both;
            height: 0;
            line-height: 0;
            font-size: 0
        }

        .over-flow {
            overflow: auto;
        }

        .outer:after {
            clear: both;
            content: '.';
            display: block;
        }

        .clearfix:after {
            clear: both;
        }
    </style>
</head>

<body>
    <div class="outer over-flow">
        <div class="div1">1</div>
        <div class="div2">2</div>
        <div class="div3">3</div>
        <!-- <div class="clear"></div> -->

    </div>
    <div class="outer">
        <div class="div1">1</div>
        <div class="div2">2</div>
        <div class="div3">3</div>
        <!-- <div class="clear"></div> -->

    </div>
    <div class="outer clearfix">
        <div class="div1">1</div>
        <div class="div2">2</div>
        <div class="div3">3</div>
        <!-- <div class="clear"></div> -->
    </div>

</body>

</html>